/*
 * =============================================================================
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <eirikb@google.com> wrote this file. As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return Eirik Brandtzæg
 * =============================================================================
 */
package no.eirikb.roboco.terminal.command;

/**
 *
 * @author eirikb
 * @author <a href="mailto:eirikb@google.com">eirikb@google.com</a>
 */
public class SET {

    private enum SETS {

        UNKNOWN, TERMINAL, INQUIRE, FILE, PROTECTION, HALT;

        public static SETS getSet(String line) {
            try {
                int pos = line.indexOf("=");
                if (pos >= 0) {
                    line = line.substring(0, pos);
                }
                pos = line.indexOf("/");
                if (pos >= 0) {
                    SETS set = SETS.getSet(line.substring(0, pos));
                    if (set == UNKNOWN) {
                        return SETS.getSet(line.substring(pos + 1));
                    } else {
                        return set;
                    }
                }
                return valueOf(line.toUpperCase());
            } catch (Exception e) {
            }
            return UNKNOWN;
        }
    }
}
